package com.hzhr.iot.user.dao;

import com.hzhr.iot.user.dao.mapper.custom.RoleEntityCustomMapper;
import com.hzhr.iot.user.dao.mapper.generator.RoleEntityMapper;
import com.hzhr.iot.user.entity.RoleEntity;
import com.hzhr.iot.user.entity.ext.RoleEntityExt;
import com.hzhr.iot.user.queryModel.custom.RoleCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class RoleDao {
    @Autowired
    RoleEntityMapper roleEntityMapper;
    @Autowired
    RoleEntityCustomMapper roleEntityCustomMapper;

    public int insert(RoleEntity record) {
        if (record == null) return 0;
        int changeCount = roleEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = roleEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(RoleEntity record) {
        if (record == null) return 0;
        int changeCount = roleEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = roleEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public RoleEntity selectEntity(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<RoleEntity> selectEntityList(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<RoleEntity> entityList = new ArrayList<>();
        for (RoleEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public RoleEntityExt selectExt(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<RoleEntityExt> selectExtList(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public RoleEntity selectEntity1(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt1(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<RoleEntity> selectEntityList1(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt1(queryModel);
        if (extList == null) return null;
        List<RoleEntity> entityList = new ArrayList<>();
        for (RoleEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public RoleEntityExt selectExt1(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt1(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<RoleEntityExt> selectExtList1(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt1(queryModel);
        return extList;
    }
    public RoleEntity selectEntity2(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt2(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<RoleEntity> selectEntityList2(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt2(queryModel);
        if (extList == null) return null;
        List<RoleEntity> entityList = new ArrayList<>();
        for (RoleEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public RoleEntityExt selectExt2(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt2(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<RoleEntityExt> selectExtList2(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<RoleEntityExt> extList = roleEntityCustomMapper.selectExt2(queryModel);
        return extList;
    }

    public int selectCount(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = roleEntityCustomMapper.selectCount(queryModel);
        return count;
    }
    public int selectCount2(RoleCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = roleEntityCustomMapper.selectCount2(queryModel);
        return count;
    }
}
